<?php
//TABLE users
$sql_users_select_all = 'SELECT * FROM `users` WHERE 1 ;';
$sql_users_select_one = 'SELECT * FROM `users` WHERE `id`=@id ;';
$sql_users_select_status = 'SELECT `status`, `lastOnlineTime` FROM `users` WHERE `id`=@id ;';
$sql_users_insert ='INSERT INTO `users`(`username`, `password`, `email`, `dob`, `avatar`, `status`, `lastOnlineTime`, `lastLocation`) VALUES (@username,@password,@email,@dob,@avatar,@status,@lastOnlineTime, @lastLocation);';
$sql_users_update ='UPDATE `users` SET `password`=@password,@email,`dob`=@dob,`avatar`=@avatar,`status`=@status,`lastOnlineTime`=@lastOnlineTime, `lastLocation`=@lastLocation WHERE `username`=@username;';
$sql_users_delete ='DELETE FROM `users` WHERE `username`=@username;';

//Table FRIENDS
$sql_friends_select_all = 'SELECT * FROM `friends` WHERE 1 ;';
$sql_friends_select_one = 'SELECT * FROM `friends` WHERE `userid`=@id ;';
$sql_friends_insert ='INSERT INTO `friends`(`userId`, `friendId`, `status`, `statusTime`) VALUES (@userid, @friendId, @status, @statusTime);';
$sql_friends_update ='UPDATE `friends` SET `status`=@status, `statusTime`=@statusTime WHERE `userid`=@username and `friendId`=@friendId ;';
$sql_friends_delete ='DELETE FROM `friends` WHERE `username`=@username; and `friendId`=@friendId ;';

//Table MESSAGES
$sql_messages_select_all = 'SELECT * `messages` ;';
$sql_messages_select_one = 'SELECT * FROM `messages` WHERE `fromid`=@fromid ;';
$sql_messages_select_status = 'SELECT `status`, `statusTime`, `location` FROM `messages` WHERE `fromid`=@fromid and `toid`=@toid` and `id`=@id ;';
$sql_messages_insert ='INSERT INTO `messages`(`fromid`, `toid`, `message`, `sentTime`, `status`, `statusTime`, `location`) VALUES (@fromid, @toid, @message,@sentTime, @status, @statusTime, @location) ;';
$sql_messages_update ='UPDATE `messages` SET `message`=@message, `sentTime`=@sentTime, `status`=@status, `statusTime`=@statusTime WHERE `fromid`=@fromid and `toid`=@toid and `id`=@id ; ';
$sql_messages_update_status ='UPDATE `messages` SET `status`=@status, `statusTime`=@statusTime WHERE `fromid`=@fromid and `toid`=@toid and `id`=@id ; ';
$sql_messages_delete ='DELETE FROM `messages` WHERE `fromid`=@fromid; and `toid`=@toid and `id`=@id;';

?>
